class AccessesController < ApplicationController
    
  def index
    @user = User.find(params[:user_id])
    @accesses = @user.accesses
  end

  def show
    @user = User.find(params[:user_id])
    @access = @user.accesses.find(params[:id])
  end

  def new
    @user = User.find(params[:user_id])
    @access = @user.accesses.build
  end

  def create
    @user = User.find(params[:user_id])
    @access = @user.accesses.build(params[:access])
    if @access.save
      redirect_to user_access_url(@user, @access)
    else
      render :action => "new"
    end
  end

  def edit
    @user = User.find(params[:user_id])
    @access = @user.accesses.find(params[:id])
  end

  def update
    @user = User.find(params[:user_id])
    @access = Access.find(params[:id])
    if @access.update_attributes(params[:access])
      redirect_to user_access_url(@user, @access)
    else
      render :action => "edit"
    end
  end

end
